using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using AgentBar.Common;
using System.Configuration;
namespace AgentBar
{
    public partial class frmWebPage : Form
    {
        private LanguageResourceManager res;
        private string LANGUAGE = "";
        public void setLang(string lang)
        {
            LANGUAGE = lang;
        }
        public frmWebPage()
        {
            InitializeComponent();
        }
        
        private void frmWebPage_Load(object sender, EventArgs e)
        {            
            try
            {
                iniForm();
                ResProfile resProfile = new ResProfile();
                wb.AllowWebBrowserDrop = false;
                wb.IsWebBrowserContextMenuEnabled = false;
                wb.WebBrowserShortcutsEnabled = false;
#if !DEBUG
                wb.ScriptErrorsSuppressed = true;
#endif
                string mainUrl = resProfile.UserUrl;
                mainUrl = mainUrl + "PersonalSet.asp";
                string UserID = "";
                string UserPass = "";

                UserID = resProfile.AgentID;
                UserPass = resProfile.AgentPassword;
                if (UserPass.Length > 0) UserPass = UserPass.Trim();
                if (UserID.Length > 0)
                {
                    mainUrl = mainUrl + "?u=" + UserID.Trim();
                    mainUrl = mainUrl + "&p=" + UserPass;
                    mainUrl = mainUrl + "&ln=" + LANGUAGE;                    
                   
                }
                wb.Navigate(mainUrl);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message );
            }
        }
        private void iniForm()
        {
            try
            {
                string language = ConfigurationManager.AppSettings["LAN"];
                if (string.IsNullOrEmpty(language)) language = "JP";
                res = new LanguageResourceManager(language);
                this.Font = new System.Drawing.Font(res.GetString("AP0000000"), float.Parse(res.GetString("AP0000001")), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, Byte.Parse("0"));
                this.Text = res.GetString("AP0020001");
                this.btnClose.Text = res.GetString("AP0020002");                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
        private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            try
            {
                string aa;
                aa = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        
    }
}